<?php 

/**
* 注册控制器RegisterController
*/
class RegisterController extends Controller
{
	
	//Index方法
	public function IndexAction()
	{
		$this->display();
	}

	public function AjaxAction()
	{
		$pregs = array(
			'username'=>array(
				'preg'=>"/^[a-z][a-z_]{3,7}$/i",
				'info'=>"用户名必须是4-8位字母",
				)，
			'phone'=>array(
				'preg'=>"/^1[0-9]{10}$/i",
				'info'=>"手机号码不正确，必须是11位数字",
				),
			'passwd'=>array(
				'preg'=>"/^[0-9a-z]{4,8}$/i",
				'info'=>"密码必须是4-8位字母或数字",
				),
			);
		if ($_POST) {
			$key = array_keys($_POST);

			$data = isset($_POST[$key[0]]) ? $_POST[$key[0]] : '';

			$preg = $pregs[$key[0]]['preg'];

			$c = preg_match($preg, $data);

			if ($c) {
				$arr = array(
					'error'=>'1',
					'info'=>$data
					);
				echo json_decode($arr);
			}else{
				$arr = array(
					'error'=>'0',
					'info'=>$pregs[$key][0]['info']
					);
				echo json_encode($arr);
			}
		}
	}
}



 ?>